﻿using Dapper;
using Microsoft.Extensions.Configuration;
using PcProject.Domain.IRepository;
using PcProject.Domain.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PcProject.Infrastructure.Repository
{
    public class LogisticsRepository : DapperRepositoryBase<Logistics>, ILogisticsRepository
    {
        //构造函数依赖注入
        public IConfiguration _configuration;
        //函数依赖注入
        public LogisticsRepository(IConfiguration configuration)
        {
            this._configuration = configuration;
            //连接字符串
            this.ConnStr = _configuration.GetConnectionString("PcMiniConnStr");
            SimpleCRUD.SetDialect(SimpleCRUD.Dialect.MySQL);
            Conn = new MySql.Data.MySqlClient.MySqlConnection(this.ConnStr);
        }


        /// <summary>
        /// 物流查询
        /// </summary>
        /// <param name="ordernumber">订单编号查询</param>
        /// <returns></returns>
        public List<Logistics> GetProductsAsync(string ordernumber)
        {
            string sql = $"select * from Product a inner join ProductCategory b on a.ProType=b.CateId";
            return Conn.Query<Logistics>(sql).ToList();
        }

    }
}
